<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <title>regist</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <link rel="stylesheet" type="text/css" href="css/style.css" />
    <link rel="stylesheet" href="css/bootstrap.min.css">
    <!-- 可选的Bootstrap主题文件（一般不用引入） -->
    <link rel="stylesheet" href="css/bootstrap-datepicker.min.css">
    <!-- jQuery文件。务必在bootstrap.min.js 之前引入 -->
    <script src="js/jquery.js"></script>
    <!-- 最新的 Bootstrap 核心 JavaScript 文件 -->
    <script src="js/bootstrap.min.js"></script>
</head>
<body onLoad="startTime()">
<div id="wrap">
    <div id="top_content">
        <div id="header">
            <div id="rightheader">
                <p id="time">

                    <br />
                </p>
            </div>
            <div id="topheader">
                <h1 id="title">
                    <a href="#">华夏医院在线平台</a>
                </h1>
            </div>
            <div id="navigation">
            </div>
        </div>
        <div id="content">
            <p id="whereami">
            </p>
            <h1 style="margin-left: 330px">
                管理员注册
            </h1>
            <form action="photos/login.html" method="post">
                <table cellpadding="0" cellspacing="0" border="0"
                       class="form_table" style="margin-left:190px">
                    <tr>
                        <td valign="middle" align="right">
                            姓名:
                        </td>
                        <td valign="middle" align="left">
                            <input type="text" class="inputgri" class="form-control" placeholder="姓名" aria-describedby="basic-addon1" v-model="admin.name" />
                        </td>
                    </tr>
                    <tr>
                        <td valign="middle" align="right">
                            联系方式:
                        </td>
                        <td valign="middle" align="left">
                            <input type="text" class="inputgri" class="form-control" placeholder="联系方式" aria-describedby="basic-addon1" v-model="admin.tel"/>
                        </td>
                    </tr>
                    <tr>
                        <td valign="middle" align="right">
                            密码:
                        </td>
                        <td valign="middle" align="left">
                            <input type="password" class="inputgri"placeholder="密码" v-model="admin.password" />
                        </td>
                    </tr>

                    <tr>
                        <td valign="middle" align="right">
                            用户名:
                        </td>
                        <td valign="middle" align="left">
                            <input type="text" class="inputgri" placeholder="用户名" v-model="admin.username" id="username" />
                        </td>
                    </tr>
                    <tr>
                        <td valign="middle" align="right">
                            院区名称:
                        </td>
                        <td valign="middle" align="left">
                            <!--									<input type="text" class="inputgri"placeholder="department" v-model="doctor.department" />-->
                            <select  v-model="admin.area">
                                <option value=1>汉口区分院</option>
                                <option value=2>武昌区分院 </option>
                                <option value=3>江汉区分院</option>
                            </select>
                        </td>
                    </tr>
                    <img id="num" :src="url" style="position:absolute;left:890px;top: 410px;height:40px"/>
                    <tr>
                        <td valign="middle" align="right">
                            验证码:
                            <a href="javascript:;" @click="getImg">换一张</a>

                        </td>
                        <td valign="middle" align="left">
                            <input type="text" class="inputgri" v-model="code" />
                        </td>
                    </tr>
                </table>
                <p>
                    <input type="button" @click="register" class="btn btn-default" value="注册 "style="margin-left:350px;width:55px" id="btn" />
                </p>
            </form>
        </div>
    </div>
    <div id="footer">
        <div id="footer_bg">
            Copyright © 小凡哥 All rights reserved.
            li123fan00@foxmail.com
        </div>
    </div>
</div>
</body>
</html>
<script src="/es_healthy/js/vue.js"></script>
<script src="/es_healthy/js/axios.min.js"></script>

<script>
    function startTime()
    {
        var today=new Date();//定义日期对象
        var yyyy = today.getFullYear();//通过日期对象的getFullYear()方法返回年
        var MM = today.getMonth()+1;//通过日期对象的getMonth()方法返回年
        var dd = today.getDate();//通过日期对象的getDate()方法返回年
        var hh=today.getHours();//通过日期对象的getHours方法返回小时
        var mm=today.getMinutes();//通过日期对象的getMinutes方法返回分钟
        var ss=today.getSeconds();//通过日期对象的getSeconds方法返回秒
        // 如果分钟或小时的值小于10，则在其值前加0，比如如果时间是下午3点20分9秒的话，则显示15：20：09
        MM=checkTime(MM);
        dd=checkTime(dd);
        mm=checkTime(mm);
        ss=checkTime(ss);
        var day; //用于保存星期（getDay()方法得到星期编号）
        if(today.getDay()==0)   day   =   "星期日 "
        if(today.getDay()==1)   day   =   "星期一 "
        if(today.getDay()==2)   day   =   "星期二 "
        if(today.getDay()==3)   day   =   "星期三 "
        if(today.getDay()==4)   day   =   "星期四 "
        if(today.getDay()==5)   day   =   "星期五 "
        if(today.getDay()==6)   day   =   "星期六 "
        document.getElementById('time').innerHTML=yyyy+"-"+MM +"-"+ dd +" " + hh+":"+mm+":"+ss+"   " + day;
        setTimeout('startTime()',1000);//每一秒中重新加载startTime()方法
    }

    function checkTime(i)
    {
        if (i<10){
            i="0" + i;
        }
        return i;
    }

</script>

<script>
    var app=new Vue({
        el:"#wrap",
        data:{
            url:"",
            admin:{
                sex:"男"
            },
            code:"",

        },
        methods:{
            age(orginnumber){
                var myDate = new Date();
                var month = myDate.getMonth() + 1;
                var day = myDate.getDate();
                var age = myDate.getFullYear() - orginnumber.substring(6, 10) - 1;
                if (orginnumber.substring(10, 12) < month || orginnumber.substring(10, 12) == month && orginnumber.substring(12, 14) <= day) {
                    age++;
                }
                console.log(age);
                this.admin.age=age;
                this.$refs.mybox.placeholder =age;
            },
            getImg(){
                this.getSrc();
            },
            //获取验证码
            getSrc(){
                var _this = this;
                axios.get("http://localhost:8080/es_healthy/user/getImage?time="+Math.random()).then(res=>{
                    console.log(res.data);
                    _this.url = res.data;
                })
            },
            //手机号验证
            isPhone(phone){
                const reg = /^[1][3,4,5,7,8][0-9]{9}$/;
                if (phone == '' || phone == undefined || phone == null) {

                } else {
                    if ((!reg.test(phone)) && phone != '') {
                        new Error('请输入正确的电话号码');
                        return false;
                    }
                    return true;
                }
            },
            //注册用户信息
            register() {
                if(this.isPhone(this.admin.tel)){
                    axios.post("http://localhost:8080/es_healthy/admin/register?code="+this.code+"&token="+sessionStorage.getItem("token"),this.admin).then(res=>{
                        console.log(res.data);
                        if(res.data.state)
                        {
                            alert(res.data.msg+",点击确定");
                            // location.href="/es_healthy/loginAdmin.html";
                            window.history.go(-1);
                        }else
                        {
                            alert(res.data.msg);
                        }

                    });
                }else
                {
                    alert("请输入正确的手机号");
                }

            }


        },
        created(){
            this.getSrc();
        }
    })
</script>